home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_plotutils.idb / usr / freeware / share / ode / atwoods.ode.z / atwoods.ode
Encoding:
Text File  |  1998-10-28  |  1.7 KB  |  44 lines

  1. # This example simulates a `swinging Atwood's machine'.  An Atwood's
  2. # machine consists of two masses joined by a taut length of cord.  The cord
  3. # is suspended from a pulley.  The heavier mass (M) would normally win
  4. # against the lighter mass (m), and pull it upward.  A `swinging' Atwood's
  5. # machine is an Atwood's machine with an additional degree of freedom: it
  6. # allows the lighter mass to swing back and forth in a plane, at the same
  7. # time as it is being drawn upward.
  8.  
  9. # Let `a' denote the angle by which the cord extending to the lighter mass
  10. # deviates from the vertical.  Let `l' denote the distance along the cord
  11. # between the pulley and the lighter mass.  Then the system of differential
  12. # equations below will describe the evolution of the system.
  13.  
  14. # You may run this example, with output to an X window in real time, by doing
  15. #
  16. #    ode < atwoods.ode | graph -T X -x 9 11 -y -1 1 -m 0 -S 1
  17. # The plot will trace out `l' and `ldot' (its time derivative).  The `-m 0
  18. # -S 1' option requests that successive datapoints not be joined by line
  19. # segments, but rather that marker symbol #1 (a point) be plotted at the
  20. # location of each datapoint.
  21.  
  22. # You may have some difficulty believing the results of this simulation.
  23. # Allowing the lighter mass to swing, it turns out, may prevent the heavier
  24. # mass from winning against it.  The system may oscillate,
  25. # non-periodically.
  26.  
  27. m = 1        # lighter mass
  28. M = 1.0625    # heavier mass
  29.  
  30. a = 0.5        # initial angle of cord from vertical, in radians
  31. adot = 0
  32. l = 10        # initial distance along cord from pulley to mass m
  33. ldot = 0
  34. g = 9.8        # acceleration due to gravity
  35.  
  36. ldot' = ( m * l * adot * adot - M * g + m * g * cos(a) ) / (m + M)
  37. l'    = ldot
  38. adot' = (-1/l) * (g * sin(a) +  2 * adot * ldot)
  39. a'    = adot
  40.  
  41. print l, ldot
  42. step 0, 400
  43.